home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 783 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  58 lines

  1. Path: transfer.stratus.com!usenet
  2. From: matt_boutin@vos.stratus.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Newbie Template Question
  5. Date: 7 Jan 1996 02:30:36 GMT
  6. Organization: Stratus Computer Inc, Marlboro MA
  7. Message-ID: <4cnb8c$qna@transfer.stratus.com>
  8. NNTP-Posting-Host: turin_h.hqsl.stratus.com
  9.  
  10. I'm new to templates and have some questions on sytax. This is
  11. a school project.  A chunk of code was given to us and we are 
  12. supposed to finish it. The code is a map and map iterator template 
  13. class. The questions that I have are for the map class. Here's the 
  14. code with questions -- 
  15.  
  16. template <class K, class V>
  17. class map
  18. {
  19. friend class MapIter<K,V>;
  20. public:
  21. Map() : i_defkey(0), i_defval(0) {init();}
  22. //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  23. // This will act as the void constructor right??
  24.  
  25. ~Map() {delete i_headp; i_headp= 0;}
  26.  
  27. // stuff omitted
  28.  
  29. private:
  30.  
  31. Map(const Map<K,V>&);
  32. //^^^^^^^^^^^^^^^^^^^
  33. // Teach says we don't need a copy constructor
  34. // this looks like a copy constructor to me.
  35. // Is it a copy constructor or can this be used as
  36. // the object constructor.
  37. // stuff omitted
  38.  
  39. MapPair<K,V> *i_headp;
  40. MapPair<K,V> *i_currentp;
  41.  
  42. const K i_defkey;
  43. V i_defval;
  44. }
  45.  
  46. My question is: 
  47. What would the constructor code look like.
  48. Having two values in the arg list is throwing me off.
  49. If the underlined segment above is the object constructor.
  50. forward declaration, what would the implementation look like.
  51.  
  52. Any help would be greatly appreciated..
  53. MB
  54.  
  55.  
  56.  
  57.  
  58.